package ZiXi;

import java.util.ArrayList;

public class TestPhonr {
    public static void main(String[] args) {
        ArrayList<Phone> list=new ArrayList<>();
       Phone p1=new Phone("小米",2999,"新机皇");
       Phone p2=new Phone("iphone8",123.2,"火爆新机");
       Phone p3=new Phone("VIVO X9s",123.2,"火爆新机");
       list.add(p1);
       list.add(p2);
       list.add(p3);
        ArrayList<Phone> lo = filter(list,1000);
        for (int i = 0; i < lo.size(); i++) {
            Phone rt=lo.get(i);
            System.out.println(rt.getName()+rt.getPrice()+rt.getType());
        }
    }
    public static ArrayList<Phone>filter(ArrayList<Phone> list,double price){
        ArrayList<Phone> newList=new ArrayList<>();
        for (int i = 0; i < list.size(); i++) {
            Phone jk=list.get(i);
            if(jk.getPrice()>price){
                newList.add(jk);
            }

        }
        return newList;
    }
}
